<?php

declare(strict_types=1);

namespace App\CustHub\Model;

use Mine\MineModel;

/**
 * @property int $id 
 * @property int $affiliate_account_id 联盟授权账号ID
 * @property string $pid 推广位ID
 * @property string $oauth_id 拼多多备案ID
 * @property string $remark 备注信息
 * @property \Carbon\Carbon $created_at 
 * @property \Carbon\Carbon $updated_at 
 * @property-read null|ChAffiliateAccount $account 
 */
class ChAffiliatePid extends MineModel
{

    public const TAG_KEY = 'affiliate_pid_tag';

    /**
     * The table associated with the model.
     */
    protected ?string $table = 'ch_affiliate_pid';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'affiliate_account_id', 'pid', 'oauth_id', 'remark', 'created_at', 'updated_at'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'affiliate_account_id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

    public function account(): \Hyperf\Database\Model\Relations\HasOne
    {
        return $this->hasOne(ChAffiliateAccount::class, 'id', 'affiliate_account_id');
    }
}
